# Contributor: Marian Buschsieweke <marian.buschsieweke@posteo.net>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
pkgname=pspp
pkgver=2.0.1
pkgrel=0
pkgdesc="GNU PSPP is a program for statistical analysis of sampled data"
url="https://www.gnu.org/software/pspp/"
arch="all"
license="GPL-3.0-only"
subpackages="$pkgname-dbg $pkgname-doc"
source="
	https://ftpmirror.gnu.org/pspp/pspp-$pkgver.tar.gz

	fix-compilation-with-gtksourceview-3.22.patch
	disable-doc.patch
	"
makedepends="
	autoconf
	automake
	cairo-dev
	gettext-dev
	gnu-libiconv-dev
	gsl-dev
	gtk+3.0-dev
	gtksourceview-dev
	libxml2-dev
	pango-dev
	pango-dev
	perl-dev
	python3
	readline-dev
	spread-sheet-widget-dev
	texinfo
	zlib-dev
	"
checkdepends="
	perl-text-diff
	"
# TODO: Unit tests hang in the CI, but succeed locally. Test again when
#       http://savannah.gnu.org/bugs/index.php?65892 is fixed.
options="!check"

prepare() {
	default_prepare

	# recognize loongarch64-alpine-linux-musl
	update_config_sub

	autoreconf
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-stripping

	make
}

check() {
	# The following tests fail now since the generation of the doc has been
	# disabled:
	_failing_tests="
		1144
		1527
		1363
		"
	for test in $_failing_tests; do
		sed -i -e "/^$test;.*\$/d" tests/testsuite
	done
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
e9be8c46d5e46b3665d1efa0e8015a0c738ceef8cdd8f8dddc7288cc6522c66a1372f7ad7be42caafbe2b37a96c31b83c3a4ad0503bdb2f0b1e3261c33529b31  pspp-2.0.1.tar.gz
428be32c607f91c907645d870d1f3449ad04f469e142794bb39ec21c7061a69e9dda7f273ac771f39d3761620179f518d9bc1c960e9e2da33fd1293bb5e04ae7  fix-compilation-with-gtksourceview-3.22.patch
745ad99afe5d8e6f1026cec769d478ee9cea026731248da1520b3b401efb27d80d8e640aa548e1c04f72b02c16cf1b7b45a59c0143d2ca6f6b8fae67ae712573  disable-doc.patch
"
